<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2018/3/13
  Time: 15:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  String jsessionid = session.getId();
%>

<style>
  table th,table td,table input{
    text-align: center;
    vertical-align: middle !important;
  }
</style>

<div class="panel" style="margin-bottom: 0">

  <div class="panel-heading">
    <ul class="nav nav-tabs">
      <li class="active"><a href="#s1" id="tab1" data-toggle="tab">基础信息</a></li>
      <li class=""><a href="#s2" id="tab2" data-toggle="tab">学习经历</a></li>
      <li class=""><a href="#s3" id="tab3" data-toggle="tab">工作经历</a></li>
      <li class=""><a href="#s4" id="tab4" data-toggle="tab">奖惩情况</a></li>
      <li class=""><a href="#s5" id="tab5" data-toggle="tab">家庭信息</a></li>
    </ul>
  </div>

  <div class="panel-heading header">
    <h3 class="panel-title" id="title">人员信息表</h3>
  </div>

  <!-- BASIC FORM ELEMENTS -->
  <!--===================================================-->
  <form id="form_person_input" class="form-horizontal">
    <div class="tab-content">
      <!-- 基本信息 -->
      <div class="tab-pane fade in active" id="s1">

        <input type="hidden" name="keyId" id="keyId" value="${person.id}"/>
        <input type="hidden" name="curDutyId" id="curDutyId" value=""/>
        <input type="hidden" name="isDirector" id="isDirector" value="${isDirector}"/>
        <input type="hidden" name="general" id="general" value="${general}"/>
        <input type="hidden" name="studyJSON" id="studyJSON" value=""/>
        <input type="hidden" name="workJSON" id="workJSON" value=""/>
        <input type="hidden" name="familyJSON" id="familyJSON" value=""/>

        <div class="form-group">
          <label class="col-md-2 control-label">姓名<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input type="text" name="name" id="name" class="form-control" placeholder="请输入姓名" value="${person.name}">
          </div>

          <label class="col-md-2 control-label">性别<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <select name="gender" id="gender" class="form-control">
              <option value="">请选择</option>
              <option value="男" <c:if test="${person.gender=='男'}">selected</c:if>>男</option>
              <option value="女" <c:if test="${person.gender=='女'}">selected</c:if>>女</option>
            </select>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">出生日期<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择出生日期" id="birthday" name="birthday" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${person.birthday}" />">
          </div>

          <label class="col-md-2 control-label">民族<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <select name="nationId" id="nationId" class="form-control">
              <option value="">请选择</option>
              <c:forEach items="${nationDict}" var="item" varStatus="index">
                <option value="${item.id}" <c:if test="${person.nation.id==item.id}">selected</c:if> >${item.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">籍贯<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入籍贯" id="origin" name="origin" class="form-control" type="text" value="${person.origin}">
          </div>

          <label class="col-md-2 control-label">出生地<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入出生地" id="birthPlace" name="birthPlace" class="form-control" type="text" value="${person.birthPlace}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">入党时间<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择入党时间" id="joinPartyDate" name="joinPartyDate" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${person.joinPartyDate}" />">
          </div>

          <label class="col-md-2 control-label">参加工作时间<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择参加工作时间" id="joinWorkDate" name="joinWorkDate" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${person.joinWorkDate}" />">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">健康状况<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入健康状况" id="health" name="health" class="form-control" type="text" value="${person.health}">
          </div>

          <label class="col-md-2 control-label">熟悉专业专长<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入熟悉专业专长" id="specialty" name="specialty" class="form-control" type="text" value="${person.specialty}">
          </div>
        </div>

        <c:if test="${isDirector==1}">
          <div class="form-group">
            <label class="col-md-2 control-label">政治面貌<i class="fa fa-asterisk txt-color-red"></i></label>
            <div class="col-md-6">
              <input placeholder="请输入政治面貌" id="zzmm" name="zzmm" class="form-control" type="text" value="${person.zzmm}">
            </div>
          </div>
        </c:if>

        <div class="form-group">
          <label class="col-md-2 control-label">身份证号<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input placeholder="请输入身份证号" id="cardId" name="cardId" class="form-control" type="text" value="${person.cardId}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">工作性质<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <select name="workNatureId" id="workNatureId" class="form-control">
              <option value="">请选择</option>
              <c:forEach items="${workNatureDict}" var="item" varStatus="index">
                <option value="${item.id}" <c:if test="${person.workNature.id==item.id}">selected</c:if> >${item.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <%--<div class="form-group">--%>
          <%--<label class="col-md-2 control-label">人员性质<i class="fa fa-asterisk txt-color-red"></i></label>--%>
          <%--<div class="col-md-6">--%>
            <%--<select name="personNatureId" id="personNatureId" class="form-control">--%>
              <%--<option value="">请选择</option>--%>
              <%--<c:forEach items="${personNatureDict}" var="item" varStatus="index">--%>
                <%--<option value="${item.id}" <c:if test="${person.personNature.id==item.id}">selected</c:if> >${item.name}</option>--%>
              <%--</c:forEach>--%>
            <%--</select>--%>
          <%--</div>--%>
        <%--</div>--%>

        <div class="form-group">
          <label class="col-md-2 control-label">最高学历<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <select name="highEduId" id="highEduId" class="form-control">
              <option value="">请选择</option>
              <c:forEach items="${eduDict}" var="item" varStatus="index">
                <option value="${item.id}" <c:if test="${person.highEdu.id==item.id}">selected</c:if> >${item.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">全日制教育</label>
          <div class="col-md-2">
            <select name="allDayEduId" id="allDayEduId" class="form-control">
              <option value="">请选择</option>
              <c:forEach items="${eduDict}" var="item" varStatus="index">
                <option value="${item.id}" <c:if test="${person.allDayEdu.id==item.id}">selected</c:if> >${item.name}</option>
              </c:forEach>
            </select>
          </div>

          <label class="col-md-2 control-label">毕业院校系及专业</label>
          <div class="col-md-2">
            <input placeholder="请输入毕业院校系及专业" id="allDaySchool" name="allDaySchool" class="form-control" type="text" value="${person.allDaySchool}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">在职教育</label>
          <div class="col-md-2">
            <select name="jobEduId" id="jobEduId" class="form-control">
              <option value="">请选择</option>
              <c:forEach items="${eduDict}" var="item" varStatus="index">
                <option value="${item.id}" <c:if test="${person.jobEdu.id==item.id}">selected</c:if> >${item.name}</option>
              </c:forEach>
            </select>
          </div>

          <label class="col-md-2 control-label">毕业院校系及专业</label>
          <div class="col-md-2">
            <input placeholder="请输入毕业院校系及专业" id="jobSchool" name="jobSchool" class="form-control" type="text" value="${person.jobSchool}">
          </div>
        </div>

        <div class="form-group">
          <label class="col-md-2 control-label">现任职务<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请输入现任职务" id="nowPost" name="nowPost" class="form-control" type="text" value="${person.nowPost}">
          </div>

          <label class="col-md-2 control-label">任现职时间<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input placeholder="请选择任现职时间" id="nowPostDate" name="nowPostDate" class="form-control date" type="text" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${person.nowPostDate}" />">
          </div>
        </div>

        <%--<div class="form-group">--%>
          <%--<label class="col-md-2 control-label">一肩挑书记情况<i class="fa fa-asterisk txt-color-red"></i></label>--%>
          <%--<div class="col-md-2">--%>
            <%--<select name="shoulder" id="shoulder" class="form-control">--%>
              <%--<option value="">请选择</option>--%>
              <%--<option value="1" <c:if test="${person.shoulder==1}">selected</c:if>>一肩挑</option>--%>
              <%--<option value="0" <c:if test="${person.shoulder==0}">selected</c:if>>否</option>--%>
            <%--</select>--%>
          <%--</div>--%>

          <%--<div class="col-md-4 col-md-offset-1" <c:if test='${person == null || person.shoulder==0}'>style="display:none"</c:if> id="shoulderDet">--%>
            <%--<div class="checkbox">--%>
              <%--<input type="checkbox" id="shoulderDet1" class="magic-checkbox" name="shoulderDet" value="已一肩挑" <c:if test="${fn:indexOf(person.shoulderDet,'已一肩挑')>=0}">checked</c:if> >--%>
              <%--<label for="shoulderDet1">已一肩挑</label>--%>

              <%--<input type="checkbox" id="shoulderDet2" class="magic-checkbox" name="shoulderDet" value="拟一肩挑连任" <c:if test="${fn:indexOf(person.shoulderDet,'拟一肩挑连任')>=0}">checked</c:if> >--%>
              <%--<label for="shoulderDet2">拟一肩挑连任</label>--%>

              <%--<input type="checkbox" id="shoulderDet3" class="magic-checkbox" name="shoulderDet" value="拟一肩挑备选" <c:if test="${fn:indexOf(person.shoulderDet,'拟一肩挑备选')>=0}">checked</c:if> >--%>
              <%--<label for="shoulderDet3">拟一肩挑备选</label>--%>
            <%--</div>--%>
          <%--</div>--%>

        <%--</div>--%>

        <div class="form-group">
          <label class="col-md-2 control-label">所在区<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <input readonly placeholder="请输入所在区" id="area" name="area" class="form-control" type="text" value="${person==null?'杨浦区':person.area}">
          </div>

          <label class="col-md-2 control-label">所在街道<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-2">
            <select name="streetId" id="streetId" class="form-control">
              <option value="">请选择</option>
              <c:forEach items="${streetDict}" var="item" varStatus="index">
                <option value="${item.id}" <c:if test="${person.street.id==item.id}">selected</c:if> >${item.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>

        <%--<div class="form-group">--%>
          <%--<label class="col-md-2 control-label">居民区<i class="fa fa-asterisk txt-color-red"></i></label>--%>
          <%--<div class="col-md-6">--%>
            <%--<select name="residentId" id="residentId" class="form-control">--%>
              <%--<option value="">请选择</option>--%>
            <%--</select>--%>
          <%--</div>--%>
        <%--</div>--%>

        <div class="form-group">
          <div class="col-md-6 col-md-offset-2">
          <table class="table table-bordered" id="person-table">
            <tbody>

            <%--2015~2018--%>
            <tr>
              <td rowspan="4" width="20%">${person.generalDict==null?'2018-2021':person.generalDict.name}</td>
              <td width="20%">居民区</td>
              <td width="60%">
                <select name="residentId" id="residentId" class="form-control" style="width: 100%">
                  <option value="">请选择</option>
                </select>
              </td>
            </tr>
            <tr>
              <td>一肩挑书记情况</td>
              <td>
                <select name="shoulder" id="shoulder" class="form-control" style="width: 100%">
                  <option value="">请选择</option>
                  <option value="1" <c:if test="${person.shoulder==1}">selected</c:if>>一肩挑</option>
                  <option value="0" <c:if test="${person.shoulder==0}">selected</c:if>>否</option>
                </select>
              </td>
            </tr>
            <tr>
              <td>一肩挑详情</td>
              <td>
                <div class="checkbox">
                  <input type="checkbox" id="shoulderDet1" class="magic-checkbox" name="shoulderDet" value="已一肩挑" <c:if test="${fn:indexOf(person.shoulderDet,'已一肩挑')>=0}">checked</c:if> <c:if test="${person.shoulder!=1}">disabled</c:if> >
                  <label for="shoulderDet1">已一肩挑</label>

                  <input type="checkbox" id="shoulderDet2" class="magic-checkbox" name="shoulderDet" value="拟一肩挑连任" <c:if test="${fn:indexOf(person.shoulderDet,'拟一肩挑连任')>=0}">checked</c:if> <c:if test="${person.shoulder!=1}">disabled</c:if> >
                  <label for="shoulderDet2">拟一肩挑连任</label>

                  <input type="checkbox" id="shoulderDet3" class="magic-checkbox" name="shoulderDet" value="拟一肩挑备选" <c:if test="${fn:indexOf(person.shoulderDet,'拟一肩挑备选')>=0}">checked</c:if> <c:if test="${person.shoulder!=1}">disabled</c:if> >
                  <label for="shoulderDet3">拟一肩挑备选</label>
                </div>
              </td>
            </tr>
            <tr>
              <td width="20%">人员性质</td>
              <td width="60%">
                <select name="personNatureId" id="personNatureId" class="form-control" style="width: 100%">
                  <option value="">请选择</option>
                  <c:forEach items="${personNatureDict}" var="item" varStatus="index">
                    <option value="${item.id}" <c:if test="${person.personNature.id==item.id}">selected</c:if> >${item.name}</option>
                  </c:forEach>
                </select>
              </td>
            </tr>

            <%--&lt;%&ndash;2018~2021&ndash;%&gt;--%>
            <%--<tr>--%>
              <%--<td rowspan="4" width="20%">2018~2021</td>--%>
              <%--<td width="20%">居民区</td>--%>
              <%--<td width="60%">--%>
                <%--<select name="residentId1" id="residentId1" class="form-control" style="width: 100%">--%>
                  <%--<option value="">请选择</option>--%>
                <%--</select>--%>
              <%--</td>--%>
            <%--</tr>--%>
            <%--<tr>--%>
              <%--<td>一肩挑书记情况</td>--%>
              <%--<td>--%>
                <%--<select name="shoulder1" id="shoulder1" class="form-control" style="width: 100%">--%>
                  <%--<option value="">请选择</option>--%>
                  <%--<option value="1" <c:if test="${person.shoulder1==1}">selected</c:if>>一肩挑</option>--%>
                  <%--<option value="0" <c:if test="${person.shoulder1==0}">selected</c:if>>否</option>--%>
                <%--</select>--%>
              <%--</td>--%>
            <%--</tr>--%>
            <%--<tr>--%>
              <%--<td>一肩挑详情</td>--%>
              <%--<td>--%>
                <%--<div class="checkbox">--%>
                  <%--<input type="checkbox" id="shoulderDet11" class="magic-checkbox" name="shoulderDet1" value="已一肩挑" <c:if test="${fn:indexOf(person.shoulderDet1,'已一肩挑')>=0}">checked</c:if> <c:if test="${person.shoulder1!=1}">disabled</c:if> >--%>
                  <%--<label for="shoulderDet11">已一肩挑</label>--%>

                  <%--<input type="checkbox" id="shoulderDet12" class="magic-checkbox" name="shoulderDet1" value="拟一肩挑连任" <c:if test="${fn:indexOf(person.shoulderDet1,'拟一肩挑连任')>=0}">checked</c:if> <c:if test="${person.shoulder1!=1}">disabled</c:if> >--%>
                  <%--<label for="shoulderDet12">拟一肩挑连任</label>--%>

                  <%--<input type="checkbox" id="shoulderDet13" class="magic-checkbox" name="shoulderDet1" value="拟一肩挑备选" <c:if test="${fn:indexOf(person.shoulderDet1,'拟一肩挑备选')>=0}">checked</c:if> <c:if test="${person.shoulder1!=1}">disabled</c:if> >--%>
                  <%--<label for="shoulderDet13">拟一肩挑备选</label>--%>
                <%--</div>--%>
              <%--</td>--%>
            <%--</tr>--%>
            <%--<tr>--%>
              <%--<td width="20%">人员性质</td>--%>
              <%--<td width="60%">--%>
                <%--<select name="personNatureId1" id="personNatureId1" class="form-control" style="width: 100%">--%>
                  <%--<option value="">请选择</option>--%>
                  <%--<c:forEach items="${personNatureDict}" var="item" varStatus="index">--%>
                    <%--<option value="${item.id}" <c:if test="${person.personNature1.id==item.id}">selected</c:if> >${item.name}</option>--%>
                  <%--</c:forEach>--%>
                <%--</select>--%>
              <%--</td>--%>
            <%--</tr>--%>

            </tbody>
          </table>
          </div>
        </div>


        <div class="form-group">
          <label class="col-md-2 control-label">照片<i class="fa fa-asterisk txt-color-red"></i></label>
          <div class="col-md-6">
            <input name="uploadify" id="photoName" placeholder="" type="file" >
            <input name="photoId" id="photoId" style="display: none" value="${person.photo.id}">
          </div>
        </div>

      </div>

      <!-- 学习经历 -->
      <div class="tab-pane fade" id="s2">
        <div class="form-group">
          <div class="col-md-8 col-md-offset-2">
            <table class="table table-bordered" id="studyTable">
              <thead>
              <tr>
                <th colspan="4">学习经历</th>
              </tr>
              <tr>
                <th width="25%">开始时间</th>
                <th width="25%">结束时间</th>
                <th width="25%">学校</th>
                <th width="25%">所获学位</th>
              </tr>
              </thead>
              <tbody id="studyTbody">

              <c:forEach items="${person.studyList}" var="item" varStatus="index">
                <tr>
                  <td><input type="text" class="form-control date" name="startDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${item.startDate}" />" ></td>
                  <td><input type="text" class="form-control date" name="endDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${item.endDate}" />" ></td>
                  <td><input type="text" class="form-control" name="school" value="${item.school}" ></td>
                  <td><input type="text" class="form-control" name="academicDegree" value="${item.academicDegree}" ></td>
                </tr>
              </c:forEach>

              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="startDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="endDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="school" ></td>--%>
                <%--<td><input type="text" class="form-control" name="academicDegree" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="startDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="endDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="school" ></td>--%>
                <%--<td><input type="text" class="form-control" name="academicDegree" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="startDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="endDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="school" ></td>--%>
                <%--<td><input type="text" class="form-control" name="academicDegree" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="startDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="endDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="school" ></td>--%>
                <%--<td><input type="text" class="form-control" name="academicDegree" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="startDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="endDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="school" ></td>--%>
                <%--<td><input type="text" class="form-control" name="academicDegree" ></td>--%>
              <%--</tr>--%>
              </tbody>
            </table>
          </div>
        </div>
      </div>

      <!-- 工作经历 -->
      <div class="tab-pane fade" id="s3">
        <div class="form-group">
          <div class="col-md-8 col-md-offset-2">
            <table class="table table-bordered" id="workTable">
              <thead>
              <tr>
                <th colspan="5">工作经历</th>
              </tr>
              <tr>
                <th width="20%">开始时间</th>
                <th width="20%">结束时间</th>
                <th width="20%">工作单位及部门</th>
                <th width="20%">职务（职级）</th>
                <th width="20%">证明人</th>
              </tr>
              </thead>
              <tbody id="workTbody">
              <c:forEach items="${person.workList}" var="item" varStatus="index">
                <tr>
                  <td><input type="text" class="form-control date" name="workStartDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${item.workStartDate}" />" ></td>
                  <td><input type="text" class="form-control date" name="workEndDate" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${item.workEndDate}" />" ></td>
                  <td><input type="text" class="form-control" name="workDept" value="${item.workDept}" ></td>
                  <td><input type="text" class="form-control" name="workPost" value="${item.workPost}" ></td>
                  <td><input type="text" class="form-control" name="proveUser" value="${item.proveUser}" ></td>
                </tr>
              </c:forEach>

              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control date" name="workStartDate" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="workEndDate" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workDept" ></td>--%>
                <%--<td><input type="text" class="form-control" name="workPost" ></td>--%>
                <%--<td><input type="text" class="form-control" name="proveUser" ></td>--%>
              <%--</tr>--%>
              </tbody>
            </table>
          </div>
        </div>
      </div>

      <!-- 奖惩情况 -->
      <div class="tab-pane fade" id="s4">
        <div class="form-group">
          <div class="col-md-8 col-md-offset-2">
            <textarea class="form-control" name="reward" rows="5" >${person.reward}</textarea>
          </div>
        </div>
      </div>

      <!-- 家庭信息 -->
      <div class="tab-pane fade" id="s5">
        <div class="form-group">
          <div class="col-md-10 col-md-offset-1">
            <table class="table table-bordered" id="familyTable">
              <thead>
              <tr>
                <th colspan="7">家庭信息</th>
              </tr>
              </thead>
              <tbody id="familyTbody">
              <tr>
                <td width="5%" style="vertical-align: middle" rowspan="5">家庭主要成员及重要社会关系</td>
                <th width="15%">称谓</th>
                <th width="15%">姓名</th>
                <th width="15%">出生年月</th>
                <th width="15%">政治面貌</th>
                <th width="15%">学历学位</th>
                <th width="19%">工作单位及职务</th>
              </tr>
              <div id="familyTbodyDiv">
                <c:forEach items="${person.familyList}" var="item" varStatus="index">
                  <tr>
                    <td><input type="text" class="form-control" name="nickName" value="${item.nickName}" ></td>
                    <td><input type="text" class="form-control" name="familyName" value="${item.familyName}" ></td>
                    <td><input type="text" class="form-control date" name="familyBirthday" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${item.familyBirthday}" />" ></td>
                    <td><input type="text" class="form-control" name="politicalStatus" value="${item.politicalStatus}" ></td>
                    <td><input type="text" class="form-control" name="familyEdu" value="${item.familyEdu}" ></td>
                    <td><input type="text" class="form-control" name="familyJob" value="${item.familyJob}" ></td>
                  </tr>
                </c:forEach>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control" name="nickName" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyName" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="familyBirthday" ></td>--%>
                <%--<td><input type="text" class="form-control" name="politicalStatus" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyEdu" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyJob" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control" name="nickName" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyName" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="familyBirthday" ></td>--%>
                <%--<td><input type="text" class="form-control" name="politicalStatus" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyEdu" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyJob" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control" name="nickName" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyName" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="familyBirthday" ></td>--%>
                <%--<td><input type="text" class="form-control" name="politicalStatus" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyEdu" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyJob" ></td>--%>
              <%--</tr>--%>
              <%--<tr>--%>
                <%--<td><input type="text" class="form-control" name="nickName" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyName" ></td>--%>
                <%--<td><input type="text" class="form-control date" name="familyBirthday" ></td>--%>
                <%--<td><input type="text" class="form-control" name="politicalStatus" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyEdu" ></td>--%>
                <%--<td><input type="text" class="form-control" name="familyJob" ></td>--%>
              <%--</tr>--%>
              </div>
              <tr id="familtLastTr">
                <td rowspan="2" style="vertical-align: middle">家庭地址</td>
                <td colspan="3" rowspan="2"><textarea style="width: 100%;height: 100%" class="form-control" name="familyAddress">${person.familyAddress}</textarea></td>
                <td>联系电话</td>
                <td colspan="2"><input type="number" class="form-control" name="phone" value="${person.phone}" ></td>
              </tr>
              <tr>
                <td>邮编</td>
                <td colspan="2"><input type="number" class="form-control" name="zipCode" value="${person.zipCode}" ></td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>

    </div>
  </form>
  </div>
  <!--===================================================-->
  <!-- END BASIC FORM ELEMENTS -->

  <div class="panel-footer">
    <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
      <i class="fa fa-lg fa-mail-reply"></i> 返回
    </a>
    <a class="btn btn-success" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存 </a>
    <c:if test="${person==null || person.processState=='Draft'}">
      <a class="btn btn-warning" id="btn-commit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 提交 </a>
    </c:if>
    <c:if test="${person!=null && person.processState=='Backed'}">
      <a class="btn btn-warning" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 再提交 </a>
    </c:if>
  </div>

</div>

<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";

  var studyAllCount = 5;
  var workAllCount = 10;
  var familyAllCount = 4;

  var residentEdId = "${person.resident.id}";

  $(function(){
    var pdata= {
      keyId:$("#keyId").val(),
      entityName:"com.fz.us.oa.core.entity.com.${isDirector==1?'Director':'Person'}"
    };
    multiDuty(pdata);
    fn_person_input_validate();
    fn_load_resident_select();
    fn_load_allTbody();
  });

  //选择街道之后修改居民区内的选择列表
  $("#streetId").change(function(){
    fn_load_resident_select();
  });

  //根据所在街道加载居民区列表
  function fn_load_resident_select(){
    var streetId = $("select[name='streetId'] option:selected").val();
    if(streetId!="" && streetId!=null){
      __ajax_get("<%=path%>/com/resident/getResidentList",{parentId:streetId},function(data){
        var list = data.data;
        $("#residentId").empty();
        $("#residentId").append('<option>请选择</option>');
        for(var i=0;i<list.length;i++){
          var isSelectEd = residentEdId==list[i].id?"selected":"";
          var newOpt = '<option value="'+list[i].id+'" '+isSelectEd+'>'+list[i].name+'</option>';
          $("#residentId").append(newOpt);
        }
      })
    }
  }

  //填充关联表格
  function fn_load_allTbody(){

    //学习记录
    var nowStudySize = $("#studyTbody tr").size();
    var addStudySize = studyAllCount-nowStudySize;
    for(var i=0;i<addStudySize;i++){
      var newStudyTr = '<tr><td><input type="text" class="form-control date" name="startDate" ></td>'+
              '<td><input type="text" class="form-control date" name="endDate" ></td>'+
              '<td><input type="text" class="form-control" name="school" ></td>'+
              '<td><input type="text" class="form-control" name="academicDegree" ></td></tr>';
      $("#studyTbody").append(newStudyTr);
    }

    //工作记录
    var nowWorkSize = $("#workTbody tr").size();
    var addWorkSize = workAllCount-nowWorkSize;
    for(var j=0;j<addWorkSize;j++){
      var newWorkTr = '<tr>'+
              '<td><input type="text" class="form-control date" name="workStartDate" ></td>'+
              '<td><input type="text" class="form-control date" name="workEndDate" ></td>'+
              '<td><input type="text" class="form-control" name="workDept" ></td>'+
              '<td><input type="text" class="form-control" name="workPost" ></td>'+
              '<td><input type="text" class="form-control" name="proveUser" ></td>'+
              '</tr>';
      $("#workTbody").append(newWorkTr);
    }

    //家庭信息
    var nowFamilySize = $("#familyTbody tr").size();
    var addFamilySize = familyAllCount-nowFamilySize+3;
    for(var k=0;k<addFamilySize;k++){
      var newFamilyTr = '<tr>'+
              '<td><input type="text" class="form-control" name="nickName" ></td>'+
              '<td><input type="text" class="form-control" name="familyName" ></td>'+
              '<td><input type="text" class="form-control date" name="familyBirthday" ></td>'+
              '<td><input type="text" class="form-control" name="politicalStatus" ></td>'+
              '<td><input type="text" class="form-control" name="familyEdu" ></td>'+
              '<td><input type="text" class="form-control" name="familyJob" ></td>'+
              '</tr>';
      $("#familtLastTr").before(newFamilyTr);
    }
  }

  $("#gender").select2({
    placeholder: "请选择性别",
    allowClear: true
  });

  $("#nationId").select2({
    placeholder: "请选择民族",
    allowClear: true
  });

  $("#workNatureId").select2({
    placeholder: "请选择工作性质",
    allowClear: true
  });

  $("#personNatureId").select2({
    placeholder: "请选择人员性质",
    allowClear: true
  });

  $("#personNatureId1").select2({
    placeholder: "请选择人员性质",
    allowClear: true
  });

  $("#highEduId").select2({
    placeholder: "请选择最高学历",
    allowClear: true
  });

  $("#allDayEduId").select2({
    placeholder: "请选择全日制教育",
    allowClear: true
  });

  $("#jobEduId").select2({
    placeholder: "请选择在职教育",
    allowClear: true
  });

  $("#streetId").select2({
    placeholder: "请选择在所在街道",
    allowClear: true
  });

  $("#residentId").select2({
    placeholder: "请选择在居民区",
    allowClear: true
  });

  $("#shoulder").select2({
    placeholder: "请选择一肩挑情况",
    allowClear: true
  });

  // 日期选择
  $('.date').datepicker({
    format: 'yyyy-mm-dd',
    weekStart: 1,
    autoclose: true,
    todayBtn: 'linked',
    todayHighlight: true,
    language: 'zh-CN'
  });

  // 附件上传
  inputLoad({
    objId:"photoName",
    entityName:"photoIds",
    sourceId:"photoId",
    jsessionid:"<%=jsessionid%>"
  });

  //一肩挑详情
  $("#shoulder").change(function(){
    if($("#shoulder option:selected").val()=="1"){
      $(":checkbox[name='shoulderDet']").removeAttr("disabled");
    }else{
      $(":checkbox[name='shoulderDet']").attr("disabled",true);
    }
  });

  // 表单数据校验
  function fn_person_input_validate() {
    __init_validate('form_person_input', {
      rules : {
        name : {
          required : true
        },
        gender : {
          required : true
        },
        birthday : {
          required : true
        },
        nationId : {
          required : true
        },
        origin:{
          required : false
        },
        birthPlace:{
          required : false
        },
        joinPartyDate : {
          required : false
        },
        joinWorkDate : {
          required : false
        },
        health : {
          required : false
        },
        specialty : {
          required : false
        },
        workNatureId : {
          required : true
        },
        personNatureId : {
          required : true
        },
        highEduId : {
          required : true
        },
        nowPost : {
          required : false
        },
        nowPostDate : {
          required : false
        },
        streetId : {
          required : true
        },
        residentId : {
          required : true
        },
        photoIds : {
          required : true
        }
      },
      messages : {
        name : {
          required : "请输入姓名"
        },
        gender : {
          required : "请选择性别"
        },
        birthday : {
          required : "请选择出生日期"
        },
        nationId : {
          required : "请选择民族"
        },
        origin : {
          required : "请输入籍贯"
        },
        birthPlace:{
          required : "请输入出生地"
        },
        joinPartyDate : {
          required : "请选择入党时间"
        },
        joinWorkDate : {
          required : "请选择参加工作时间"
        },
        health : {
          required : "请输入健康状况"
        },
        specialty : {
          required : "请输入熟悉专业专长"
        },
        workNatureId : {
          required : "请选择工作性质"
        },
        personNatureId : {
          required : "请选择人员性质"
        },
        highEduId : {
          required : "请选择最高学历"
        },
        nowPost : {
          required : "请输入现任职务"
        },
        nowPostDate : {
          required : "请选择现任职时间"
        },
        streetId : {
          required : "请选择所在街道"
        },
        residentId : {
          required : "请选择居民区"
        },
        photoIds : {
          required : "请上传照片"
        }
      }
    });
  }

  //保存
  $("#btn-save-common").click(function(){
    if(!checkPhoto()){
      return false;
    }
    createStudy();
    createWork();
    createFamily();
    __confirm_dialog("提示","确定保存吗？",function(){
      __form_save("form_person_input", "<%=path%>/com/${isDirector==1?'director':'person'}/save",function(){
        $("#apply-re-common").trigger("click");
      })
    });
  });

  //提交
  $("#btn-commit-common,#btn-recommit-common").click(function(){
    createStudy();
    createWork();
    createFamily();
    if (!$('#form_person_input').valid()) {
      __toastr_error("请检查基本信息");
      return false;
    }
    __confirm_dialog("提示：","确定提交么?",function(){
      __form_save("form_person_input", "<%=path%>/com/${isDirector==1?'director':'person'}/commit",function(){
        $("#apply-re-common").trigger("click");
      })
    });
  });

  //创建学习经历JSON
  function createStudy(){
    var studyList = new Array();
    var studyTrs = $("#studyTbody tr");
    for(var i=0;i<studyTrs.length;i++){
      var study = new Object();
      study.startDate = studyTrs.eq(i).find("input[name='startDate']").val();
      study.endDate = studyTrs.eq(i).find("input[name='endDate']").val();
      study.school = studyTrs.eq(i).find("input[name='school']").val();
      study.academicDegree = studyTrs.eq(i).find("input[name='academicDegree']").val();
      studyList.push(study);
    }
    var studyJSON = JSON.stringify(studyList);
    $("#studyJSON").val(studyJSON);
  }

  //创建工作经历JSON
  function createWork(){
    var workList = new Array();
    var workTrs = $("#workTbody tr");
    for(var i=0;i<workTrs.length;i++){
      var work = new Object();
      work.workStartDate = workTrs.eq(i).find("input[name='workStartDate']").val();
      work.workEndDate = workTrs.eq(i).find("input[name='workEndDate']").val();
      work.workDept = workTrs.eq(i).find("input[name='workDept']").val();
      work.workPost = workTrs.eq(i).find("input[name='workPost']").val();
      work.proveUser = workTrs.eq(i).find("input[name='proveUser']").val();
      workList.push(work);
    }
    var workJSON = JSON.stringify(workList);
    $("#workJSON").val(workJSON);
  }

  //创建家庭信息JSON
  function createFamily(){
    var familyList = new Array();
    var familyTrs = $("#familyTbody tr");
    for(var i=1;i<5;i++){ //只取前四行
      var family = new Object();
      family.nickName = familyTrs.eq(i).find("input[name='nickName']").val();
      family.familyName = familyTrs.eq(i).find("input[name='familyName']").val();
      family.familyBirthday = familyTrs.eq(i).find("input[name='familyBirthday']").val();
      family.politicalStatus = familyTrs.eq(i).find("input[name='politicalStatus']").val();
      family.familyEdu = familyTrs.eq(i).find("input[name='familyEdu']").val();
      family.familyJob = familyTrs.eq(i).find("input[name='familyJob']").val();
      familyList.push(family);
    }
    var familyJSON = JSON.stringify(familyList);
    $("#familyJSON").val(familyJSON);
  }

  //验证附件
  function checkPhoto(){
    var photoIds = $("input[name='photoIds']").val();
    var photoLi = $("ol[id='photoIds']>li");
    if(photoLi.size()>1){
      __toastr_error("照片只能上传一张");
      return false;
    }else{
      var name = photoLi.eq(0).find(".fname").text();
      var index = name.lastIndexOf(".");
      var n = name.substring(index+1,name.length);
      if("png,jpg,jpeg,gif".indexOf(n) != -1){
        return true;
      }else{
        __toastr_error("只支持png,jpg,jpeg,gif格式");
        return false;
      }
    }
  }

  //返回视图
  $("#apply-re-common").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      returnToHashUrl()
    }
  });


</script>